package com.cangxuan.manage.service.impl;

import com.cangxuan.manage.dao.IBannerDao;
import com.cangxuan.manage.entity.Banner;
import com.cangxuan.manage.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *Author:罗健
 */
@Service
public class BannerServiceImpl implements IBannerService {
    IBannerDao bannerDao;
    @Autowired
    public void setBannerDao(IBannerDao bannerDao) {
        this.bannerDao = bannerDao;
    }

    @Override
    public List<Banner> getBanner() {
        return bannerDao.selectBanner();
    }

    @Override
    public boolean saveBanner(Banner banner) {
        return banner.getId() == 0 ? bannerDao.insertBanner(banner) > 0 : bannerDao.updateBanner(banner) > 0;
    }

    @Override
    public boolean removeBanner(int id) {
        return bannerDao.deleteBanner(id)>0;
    }

    @Override
    public boolean upDataBanner(Banner banner) {
        return bannerDao.updateBanner(banner)>0;
    }
}
